import React, { useState } from "react";
import { Modal, Button } from "antd";
import DishList from "@/component/dishList";

import "./index.less";

const AddDish: React.FC = () => {
  const [isShowModal, setIsShowModal] = useState(false);

  const handleSuccess = () => {
    setIsShowModal(false);
  };

  return (
    <div>
      {!window.useData.getState().userInfo?.token && (
        <h1>没有登录，发送请求都是失败的噢</h1>
      )}
      <Button type="primary" onClick={() => setIsShowModal(true)}>
        添加菜单
      </Button>
      <Modal
        open={isShowModal}
        onCancel={() => setIsShowModal(false)}
        footer={null}
      >
        <DishList isAdd={true} addSuccess={handleSuccess} />
      </Modal>
    </div>
  );
};

export default AddDish;
